<?php

declare(strict_types=1);

namespace Plugin\Attractions\AttractionManagement\Listener;

use Hyperf\Coroutine\Coroutine;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\MainWorkerStart;
use Hyperf\Redis\Redis;
use Plugin\Attractions\AttractionManagement\Repository\AttractionScoreRepository;

#[Listener()]
class RefreshScoreListener implements ListenerInterface
{
    public function __construct(protected readonly Redis $redis, protected readonly AttractionScoreRepository $scoreRepository) {}

    public function listen(): array
    {
        return [
            MainWorkerStart::class
        ];
    }

    public function process(object $event): void
    {
        Coroutine::create(function () {
            $this->scoreRepository->statisticScore();
        });
    }
}
